const { DataTypes } = require('sequelize');
const seq = require('../db/seq');

const NewsContent = seq.define('information', {
  id: {
    type: DataTypes.INTEGER,
    autoIncrement: true,
    primaryKey: true
},
title: {
    type: DataTypes.STRING,
    allowNull: false
},
region: {
    type: DataTypes.STRING,
    allowNull: false
},
date1: {
    type: DataTypes.DATE,
    allowNull: false
},
date2: {
    type: DataTypes.DATE,
    allowNull: true
},
delivery: {
    type: DataTypes.STRING,
    allowNull: true
},
type: {
    type: DataTypes.STRING,
    allowNull: true
},
resource: {
    type: DataTypes.STRING,
    allowNull: true
},
desc: {
    type: DataTypes.TEXT,
    allowNull: true
},
image: {
    type: DataTypes.STRING,
    allowNull: true
},
saved: {
    type: DataTypes.BOOLEAN,
    defaultValue: false
},
published: {
    type: DataTypes.BOOLEAN,
    defaultValue: true
},
content: {
    type: DataTypes.TEXT,
    allowNull: true
},
created_at: {
    type: DataTypes.DATE,
    defaultValue: DataTypes.NOW,
    field: 'created_at' // 确保字段名称正确
},
updated_at: {
    type: DataTypes.DATE,
    defaultValue: DataTypes.NOW,
    onUpdate: DataTypes.NOW,
    field: 'updated_at' // 确保字段名称正确
}
}, {

timestamps: false, // 由于我们手动定义了 created_at 和 updated_at，设为 false
});

module.exports = NewsContent;